<template>
  <div :class="['base-form-item', 'd-flex', `${align}`, ' mr-3', 'my-2']">
    <div
      v-if="label"
      :style="{ flex: `0 0 ${labelWidth}px` }"
      :class="['text-right', 'mr-2', labelFont]"
    >
      <span :class="{ required: required }" style="font-size: 14px">{{ label }}</span>
    </div>
    <div class="d-flex flex-wrap" :style="{ width: formatWidth }">
      <slot />
    </div>
  </div>
</template>

<script>
export default {
  name: 'BaseFormItem',
  props: {
    label: {
      type: String,
      defult: () => ''
    },
    width: {
      default: () => 190
    },
    labelWidth: {
      type: Number,
      default: () => 60
    },
    align: {
      type: String,
      default: 'align-center'
    },
    labelFont: {
      type: String,
      default: 'body-2'
    },
    required: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    formatWidth() {
      return Number(this.width) ? `${this.width}px` : this.width
    }
  }
}
</script>
<style lang="scss" scoped>
.required {
  position: relative;
  &::before {
    content: '*';
    position: absolute;
    top: 0;
    left: -8px;
  }
}
</style>
